﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MINERP.MODEL.FoundationModel;

namespace MINERP.MODEL.StartOrder
{
    /// <summary>
    /// 照片的结构
    /// </summary>
    public class PhotoInfo : PhotoInfo_Info
    {
        public long PhotoLength { get; set; }               //照片长度(同一个产品中取得长度最大的，用于CRC校验)
        public int PhotoDPI { get; set; }//照片分辨率
                   
        public string PhotoArea { get; set; }               //面积
        public string Unit { get; set; }                    //单位(在非设计类产品单位变化时使用)
        public bool Selected { get; set; }                  //照片是否被选中
        public bool IsPiPei { get; set; }                   //当产品是不需要设计的产品时，照片是否与产品尺寸匹配
        public int PhotoNum { get; set; }                   //照片数量
        public string CrcMark { get; set; }                 //CRC码
        public bool IsInDirectory { get; set; }             //是否在选中的目录中
        public string FinalPath { get; set; }               //最终路径
        public string PhotoWH                               //照片宽高
        {
            get 
            { 
                switch (Unit)
	            {
                    case "厘米":
                        if(Width>Height)
                            return string.Format("{0}X{1}cm",Math.Round( (decimal)(Width * 2.54),2,MidpointRounding.AwayFromZero), Math.Round((decimal)(Height * 2.54),2,MidpointRounding.AwayFromZero));
                        else
                            return string.Format("{1}X{0}cm", Math.Round((decimal)(Width * 2.54), 2, MidpointRounding.AwayFromZero), Math.Round((decimal)(Height * 2.54), 2, MidpointRounding.AwayFromZero));
                    case "英寸":
                        if(Width >Height)
                            return string.Format("{0}X{1}inch",Math.Round((decimal)Width,2,MidpointRounding.AwayFromZero),Math.Round((decimal)Height,2,MidpointRounding.AwayFromZero));
                        else
                            return string.Format("{1}X{0}inch", Math.Round((decimal)Width, 2, MidpointRounding.AwayFromZero), Math.Round((decimal)Height, 2, MidpointRounding.AwayFromZero));
                    case "米":
                        if(Width>Height)
                            return string.Format("{0}X{1}m", Math.Round((decimal)(Width * 2.54 / 100), 2,MidpointRounding.AwayFromZero), Math.Round((decimal)(Height * 2.54 / 100), 2,MidpointRounding.AwayFromZero));
                        else
                            return string.Format("{1}X{0}m", Math.Round((decimal)(Width * 2.54 / 100), 2, MidpointRounding.AwayFromZero), Math.Round((decimal)(Height * 2.54 / 100), 2, MidpointRounding.AwayFromZero));
                    default :
                        if(Width >Height)
		                    return string.Format("{0}X{1}cm",Math.Round( (decimal)(Width * 2.54),2,MidpointRounding.AwayFromZero), Math.Round((decimal)(Height * 2.54),2,MidpointRounding.AwayFromZero));
                        else
                            return string.Format("{1}X{0}cm", Math.Round((decimal)(Width * 2.54), 2, MidpointRounding.AwayFromZero), Math.Round((decimal)(Height * 2.54), 2, MidpointRounding.AwayFromZero));
	            }
                
            }
         }                //照片尺寸

        /// <summary>
        /// 是否为图片格式
        /// </summary>
        public bool isPictrue { get; set; }
        public bool isNotSizeInProduct { get; set; }
    }
}
